package com.shrct.businessprocess.purchase.impl;

import com.shrct.businessprocess.product.RCServiceInfo;
import com.shrct.businessprocess.project.RCProjectMoney;
import com.shrct.businessprocess.purchase.RCBudgetContractProductItem;
import com.shrct.businessprocess.purchase.RCContractItemPromisedService;
import com.shrct.businessprocess.purchase.impl.RCBudgetContractProductItemImpl;
import com.shrct.businessprocess.purchase.proxy.RCContractItemPromisedServiceProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCCONTRACTITEMPROMISEDSERVICE_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rccontractitempromisedservice")
public class RCContractItemPromisedServiceImpl extends BaseModelObject implements RCContractItemPromisedService {
  public RCContractItemPromisedServiceImpl() {
    super();
  }
  
  public RCContractItemPromisedServiceImpl(final RCBudgetContractProductItem productItem) {
    super();
    this.productItem = productItem;
  }
  
  private String name;
  
  public String getName() {
    return this.name;
  }
  
  public RCContractItemPromisedService setName(final String name) {
    this.name = name;
    return this;			
    
  }
  
  @JoinColumn(name = "productItem_id")
  @ManyToOne(targetEntity = RCBudgetContractProductItemImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCBudgetContractProductItem productItem;
  
  public RCBudgetContractProductItem getProductItem() {
    return this.productItem;
  }
  
  public RCContractItemPromisedService setProductItem(final RCBudgetContractProductItem productItem) {
    this.productItem = productItem;
    return this;			
    
  }
  
  @Embedded
  @AttributeOverrides(value = { @AttributeOverride(name = "monthes", column = @Column(name = "serviceInfo_monthes") ), @AttributeOverride(name = "workaround", column = @Column(name = "serviceInfo_workaround") ) } )
  @AssociationOverrides(value = { @AssociationOverride(name = "serviceLevel", joinColumns = @JoinColumn(name = "serviceInfo_serviceLevel") ), @AssociationOverride(name = "serviceResponseTime", joinColumns = @JoinColumn(name = "serviceInfo_serviceResponseTime") ), @AssociationOverride(name = "serviceDuration", joinColumns = @JoinColumn(name = "serviceInfo_serviceDuration") ) } )
  private RCServiceInfo serviceInfo = com.shrct.businessprocess.product.RCServiceInfo.create();
  
  public RCServiceInfo getServiceInfo() {
    return this.serviceInfo;
  }
  
  public RCContractItemPromisedService setServiceInfo(final RCServiceInfo serviceInfo) {
    this.serviceInfo = serviceInfo;
    return this;			
    
  }
  
  @Embedded
  @AttributeOverrides(value = { @AttributeOverride(name = "amount", column = @Column(name = "servicePrice_amount") ), @AttributeOverride(name = "workaround", column = @Column(name = "servicePrice_workaround") ) } )
  @AssociationOverrides(value = @AssociationOverride(name = "exchange", joinColumns = @JoinColumn(name = "servicePrice_exchange") ) )
  private RCProjectMoney servicePrice = com.shrct.businessprocess.project.RCProjectMoney.create();
  
  public RCProjectMoney getServicePrice() {
    return this.servicePrice;
  }
  
  public RCContractItemPromisedService setServicePrice(final RCProjectMoney servicePrice) {
    this.servicePrice = servicePrice;
    return this;			
    
  }
  
  public static RCContractItemPromisedService create(final RCBudgetContractProductItem productItem, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.purchase.RCContractItemPromisedService rCContractItemPromisedService = new com.shrct.businessprocess.purchase.impl.RCContractItemPromisedServiceImpl(
    	productItem
    );
    objectFactory.create(rCContractItemPromisedService);
    return rCContractItemPromisedService;			
    
  }
  
  public static RCContractItemPromisedService createRCContractItemPromisedServiceImpl(final RCBudgetContractProductItem productItem, final IObjectFactory objectFactory, final Procedure1<RCContractItemPromisedService> init) {
    com.shrct.businessprocess.purchase.RCContractItemPromisedService rCContractItemPromisedService = new com.shrct.businessprocess.purchase.impl.RCContractItemPromisedServiceImpl(
    	productItem
    );
    objectFactory.create(rCContractItemPromisedService);
    init.apply(rCContractItemPromisedService);
    
    return rCContractItemPromisedService;			
    
  }
  
  public RCContractItemPromisedServiceProxy toProxy() {
    com.shrct.businessprocess.purchase.proxy.RCContractItemPromisedServiceProxy proxy = new com.shrct.businessprocess.purchase.proxy.RCContractItemPromisedServiceProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
